

/**
 * 时间转换（秒转为时分秒）
 * @param {*} data 秒
 * @returns 
 */
export function getTime(data) {
    var time;
    if (data < 60) {
        time = data + "秒";
    } else if (data >= 60 && data < 3600) {
        time = Math.floor(data / 60) + "分" + (data % 60) + "秒";
    } else {
        var h = Math.floor(data / 3600);
        data -= h * 3600;
        var m = Math.floor(data / 60);
        data -= m * 60;
        time = h + "小时" + m + "分" + data + "秒";
    }
    return time;
}

/**
 * 长度单位换算
 * @param {*} data 
 * @returns 
 */
export function getDistance(data) {
    var dis;
    data = parseFloat(data).toFixed(2);
    data = parseFloat(data);
    if (data >= 1000) {
        dis = (data / 1000).toFixed(3) + "千米";
    } else {
        dis = data + "米";
    }
    return dis;
}

export function carts3Tolonlat(cartesian) {
    let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
    let lon = Cesium.Math.toDegrees(cartographic.longitude);
    let lat = Cesium.Math.toDegrees(cartographic.latitude);
    // let height = cartographic.height;
    return {
        lat: lat,
        lon: lon,
    };
}